package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TDecname;
import com.ruoyi.system.service.ITDecnameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 堆垛机Controller
 *
 * @author ruoyi
 * @date 2024-09-10
 */
@RestController
@RequestMapping("/system/decname")
public class TDecnameController extends BaseController
{
    @Autowired
    private ITDecnameService tDecnameService;

    /**
     * 查询堆垛机列表
     */
    @PreAuthorize("@ss.hasPermi('system:decname:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDecname tDecname)
    {
        startPage();
        List<TDecname> list = tDecnameService.selectTDecnameList(tDecname);
        return getDataTable(list);
    }

    /**
     * 导出堆垛机列表
     */
    @PreAuthorize("@ss.hasPermi('system:decname:export')")
    @Log(title = "堆垛机", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDecname tDecname)
    {
        List<TDecname> list = tDecnameService.selectTDecnameList(tDecname);
        ExcelUtil<TDecname> util = new ExcelUtil<TDecname>(TDecname.class);
        util.exportExcel(response, list, "堆垛机数据");
    }

    /**
     * 获取堆垛机详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:decname:query')")
    @GetMapping(value = "/{decid}")
    public AjaxResult getInfo(@PathVariable("decid") String decid)
    {
        return success(tDecnameService.selectTDecnameByDecid(decid));
    }

    /**
     * 新增堆垛机
     */
    @PreAuthorize("@ss.hasPermi('system:decname:add')")
    @Log(title = "堆垛机", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDecname tDecname)
    {
        return toAjax(tDecnameService.insertTDecname(tDecname));
    }

    /**
     * 修改堆垛机
     */
    @PreAuthorize("@ss.hasPermi('system:decname:edit')")
    @Log(title = "堆垛机", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDecname tDecname)
    {
        return toAjax(tDecnameService.updateTDecname(tDecname));
    }

    /**
     * 删除堆垛机
     */
    @PreAuthorize("@ss.hasPermi('system:decname:remove')")
    @Log(title = "堆垛机", businessType = BusinessType.DELETE)
	@DeleteMapping("/{decids}")
    public AjaxResult remove(@PathVariable String[] decids)
    {
        return toAjax(tDecnameService.deleteTDecnameByDecids(decids));
    }
}
